package com.lyn.pluginbazaar.controller;

import com.lyn.pluginbazaar.annotation.Login;
import com.lyn.pluginbazaar.api.ApiAdapter;
import com.lyn.pluginbazaar.api.PluginAdapter;
import com.lyn.pluginbazaar.entity.AddPlugin;
import com.lyn.pluginbazaar.entity.PagingQuery;
import com.lyn.pluginbazaar.entity.Result;
import com.lyn.pluginbazaar.entity.UpdatePlugin;
import com.lyn.pluginbazaar.service.PluginService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "插件")
@CrossOrigin
@RestController
@RequestMapping(value = "/plugin")
public class PluginController implements PluginAdapter {

    @Autowired
    private PluginService pluginService;

    @Login
    @PostMapping(value = "/addPlugin")
    @Override
    public Result addPlugin(@RequestBody AddPlugin addPlugin) {
        return pluginService.addPlugin(addPlugin);
    }

    @Login
    @GetMapping(value = "/deletePlugin")
    @Override
    public Result deletePlugin(@RequestParam Long id) {
        return pluginService.deletePlugin(id);
    }

    @Login
    @PostMapping(value = "/updatePlugin")
    @Override
    public Result updatePlugin(@RequestBody UpdatePlugin updatePlugin) {
        return pluginService.updatePlugin(updatePlugin);
    }

    @PostMapping(value = "/pagingQuery")
    @Override
    public Result pagingQuery(@RequestBody PagingQuery pagingQuery) {
        return pluginService.pagingQuery(pagingQuery);
    }

    @Login
    @PostMapping(value = "/count")
    @Override
    public Result count(@RequestBody PagingQuery pagingQuery) {
        return pluginService.count(pagingQuery);
    }
}
